package com.atguigu;

import com.atguigu.mapper.EmpMapper;
import com.atguigu.pojo.Emp;
import com.atguigu.service.EmployeeService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;

import javax.sql.DataSource;
import java.sql.SQLException;
import java.util.List;

/**
 * @author 琉
 * @create 2021-09-10 11:22
 */
@SpringJUnitConfig(locations = "classpath:spring-persist.xml")
public class testMybatis {

    @Autowired
    private DataSource dataSource;
//    @Autowired
//    private EmpMapper empMapper;

    //从mapper持久层换成service层注入
    @Autowired
    private EmployeeService employeeService;

    @Test
    public void test1(){
        List<Emp> empList = employeeService.findAll();
        for (Emp emp : empList) {
            System.out.println(emp.toString());
        }
    }

    @Test
    public void testDataSource() throws SQLException {
        System.out.println(dataSource.getConnection());
    }

}
